﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace IslandInterloper.Engine
{
    internal class AvatarCommodities : GameClientCollectionStringKeyed<AvatarCommodity>
    {
        internal AvatarCommodities(Game theGame):
            base(theGame)
        {
            foreach (string commodity in Game.Commodities.Keys)
            {
                collection.Add(commodity, new AvatarCommodity(Game, commodity));
            }
        }
        internal AvatarCommodities(Game theGame, XElement element)
            : base(theGame,element)
        {
        }
        protected override AvatarCommodity LoadItemFromXElement(XElement element)
        {
            return new AvatarCommodity(Game, element);
        }
        public double TotalTonnage
        {
            get
            {
                double result = 0.0;
                foreach (string commodity in Keys)
                {
                    result += this[commodity].Tonnage;
                }
                return result;
            }
        }
    }
}
